#ifndef PLUGOBJECT_H
#define PLUGOBJECT_H

#include "common/common.h"
#include "common/list.h"
#define PLUG_MAX_NAME_LENGH 30
#define PLUG_MAX_FUN_NAME_LENGH 30
/*in 和out 是相对于插件本身的职责，从设备外部获取数据为in，从设备内出输出数据为out*/
/******************GROUP**************/
#define GROUP_ALL 0
#define GROUP_MANGER 1
#define GROUP_CODER_DECODER 2
#define GROUP_IN 3
#define GROUP_OUT 4
#define GROUP_OTHER 5
/***********callback***************/
/*input callback*/
typedef INT32 (*in_callback)(PVOID data);
//BOOL (*in_callback_cmp)(PVOID,PVOID);
typedef INT32 (*addOut)(in_callback in);
typedef INT32 (*delOut)(in_callback in);
#define LINKPLUG(A,B) A->addOut(B->in_callback);
/********depend**********/
#define DEPEND_NONE	0	/*no action*/
#define DEPEND_IN	1
#define DEPEND_OUT	2
#define DEPEND_IN_OUT	3
typedef struct _depend
{
	CHAR	plugName[PLUG_MAX_NAME_LENGH];
    UINT32	dependAction;
	UINT8	group;
}depend,*pDepend;
#if 0
/*plug package*/
struct _packageObject
{
    INT32 srcPlugID;   /*who send the package*/
    INT32 destPlugID;   /*who resaved this package*/
    INT32 destPlugGroup;    /*which group can recvice this package*/
    INT32 packageType;
    PVOID pdata;

};
#endif

/*
*plug object class
*all plug derived to object class
*/
typedef struct _plugObject
{
        CHAR    	name[PLUG_MAX_NAME_LENGH];
        UINT32  	ID;
	PVOID		dlhandle;
	List		dependList;
        List    	inList;         /*input buffer*/
        List    	outList;        /*ouput other plug in_callback list*/
        UINT8   	group;
	//plugObject*	(*init)(pPlugObject t);
        BOOL    	(*in_callback_cmp)(PVOID,PVOID);
      	INT32   	(*addOut)(struct _plugObject* t,in_callback in);
	INT32		(*delOut)(struct _plugObject* t,in_callbcak in);
        PVOID   	(*thread_main)(void*);
        VOID    	(*thread_run)(struct _plugObject *t);
	INT32		(*destroy)(pPlugObject t);
} plugObject,*pPlugObject;

/*struct compare function,used by list*/
extern UINT32 cmp_plug(PVOID pdata,PVOID param);
extern BOOL cmp_depend(PVOID pdata,PVOID param);
/*super function*/
extern INT32 super_addout(pPlugObject t,in_callback in);
extern INT32 super_delout(pPlugObject t,in_callback in);
extern INT32 super_add_depend_list(pPlugObject t,pDepend dep);

#endif
